<!DOCTYPE html>
<<<<<<< HEAD
<html style="font-size: 34.722px;"><head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="viewport" content="width=device-width,inital-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <meta name="apple-mobile-web-app-capable" content="yes"/>
    <meta name="apple-mobile-web-app-status-bar-style" content="black"/>
    <meta name="format-detection" content="telephone=no, email=no"/>
    <title>骡窝窝积分商城</title>
    <link href="/mall/css/reset2.css" rel="stylesheet" type="text/css"/>
    <link href="/mall/css/css2.css" rel="stylesheet" type="text/css"/>
    <link rel="stylesheet" type="text/css" href="/mall/css/base.css"/>
    <link rel="stylesheet" type="text/css" href="/mall/css/mui.min.css"/>
    <link rel="stylesheet" type="text/css" href="/mall/css/loaders.min.css"/>
    <link rel="stylesheet" type="text/css" href="/mall/css/loading.css"/>
    <link rel="stylesheet" href="/js/plugins/dialog2/dialog.css">
    <script src="/js/jquery/jquery.min.js"></script>
    <script src="/mall/css/base2.css"></script>
    <script src="/mall/js/jquery.lazyload.js"></script>
    <script src="/mall/js/rem.js"></script>
    <script src="/mall/js/aui-car2.js"></script>
    <script src="/js/plugins/form/jquery.form.js"></script>
    <script src="/js/plugins/jrender/jrender.min.js"></script>
    <script src="/js/plugins/dialog2/dialog.min.js"></script>
    <script src="/js/common.js"></script>

    <script>
        $(function () {
            var user = $.parseJSON(sessionStorage.getItem("user"));
            var params = getParams();

            var arr = $.map(params, function (a) {
                return a;
            })
            console.log(arr);   //获取所有商品id
            jQuery.ajaxSettings.traditional = true;
            var ids = params.ids0;
            var id = params.id;

            if (ids || arr.length > 1){   //购物车进来
                console.log("111");
                $.get("/users/list",{ids: arr},function (data) {
                    console.log(data);
                })

            }else if(id){ //单款商品过来
                $.get("/products/getProductById", {id:params.id} ,function (data) {    //发请求获取商品信息(单种商品)
                    var json = {product: data}
                    var json1 = {list: json}
                    $("#listProduct").renderValues(json1);
                    $(".transFee").renderValues(json1);
                    count = data.credits;
                    $("#unit").html(count);
                    $("#dsp").html(count);
                })
            }


            $.get("/credits/" + user.id, function (data1) {
                //立即支付按钮 绑定功能
                $("#immediatePayment").click(function () {
                    //如果积分足够
                    if (data1.credits >= $("#unit").html()) {
                        /*$.ajax({
                            type: "PUT",
                            data: {arr: arr},
                            url: "/persons/updateType"
                        })*/
                        var count = $("#unit").html();  //需要支付的积分
                        var dataParams = {};
                        dataParams["userId"] = user.id;
                        dataParams["totalCredits"] = count;
                        console.log(dataParams);
                        /*$.ajax({
                            type: "PUT",
                            data: dataParams,
                            url: "/integrals/updateIntegral"
                        })*/
                        $.post("/credits/update",dataParams,function (data) {
                            //减去相应积分
                        })
                        location.href = "/mine/order-ok.html?id=" + $("#unit").html();
                    } else {    //否则积分不足,提示充值
                        $(document).dialog({
                            overlayClose: true,
                            content: '积分不足,请先去充值!'
                        });
                    }
                })
            })


            /* if (arr) {
                 $.get("/users", {ids: arr, userId: user.id}, function (data)
                 {  //发请求获取用户当前订单
                     var count = 0;
                     //console.log(data.list[0].number);
                     //console.log(data);
                     var product = data.list.length;
                     if (params.id0) {   //如果有
                         $("#listProduct").renderValues(data);
                         $(".transFee").renderValues(data);
                         //循环获取所有积分
                         $.each(data.list, function (index, ele) {
                             count += ele.product.credits * ele.num;
                         })
                         $("#unit").html(count);
                         $("#dsp").html(count);

                     } else {                               //当前商品id
                         $.get("/products/getProductById" + params.id, function (data) {    //发请求获取商品信息(单种商品)
                             var json = {product: data}
                             var json1 = {list: json}
                             console.log(json1);
                             $("#listProduct").renderValues(json1);
                             $(".transFee").renderValues(json1);
                             count = data.credits;
                             $("#unit").html(count);
                             $("#dsp").html(count);
                         })

                     }

                     //获取总积分
                     console.log(arr);
                     $.get("/integrals/" + user.id, function (data1) {
                         $("#immediatePayment").click(function () {
                             if (data1 >= $("#unit").html()) {
                                 // jQuery.ajaxSettings.traditional = true;
                                 $.ajax({
                                     type: "PUT",
                                     data: {arr: arr},
                                     url: "/persons/updateType"
                                 })
                                 var count = data1 - $("#unit").html();
                                 var dataParams = {};
                                 dataParams["userId"] = user.id;
                                 dataParams["totalIntegral"] = count;
                                 console.log(dataParams);
                                 $.ajax({
                                     type: "PUT",
                                     data: dataParams,
                                     url: "/integrals/updateIntegral"
                                 })
                                 location.href = "/mine/order-ok.html?id=" + $("#unit").html();
                             } else {
                                 $(document).dialog({
                                     overlayClose: true,
                                     content: '积分不足!'
                                 });
                             }
                         })
                     })
                 })
             }*/
        })
    </script>
</head>

<body>
<div class="wrap clearfix">
    <header class="mui-bar mui-bar-nav" id="header" style="background-color: #7587ff">
        <a class="" href="javascript:history.go(-1)">
            <i class="iconfont icon-fanhui"></i>
        </a>
        <h4>订单结算</h4>
    </header>
    <div class="clear"></div>
    <!-- header end -->
    <ul class="list-tab btline mt10 clearfix">
        <li class="item">
            <a class="order-addr tap pl-24 arrow" href="/mine/myAddress.html">
                <i class="icon-addr icon"></i>
                <span class="">广东省广州市天河区大地商务港D栋702</span><span class="fr c2">新的地址</span>
                <i class="icon-arrow icon"></i>
            </a>
        </li>
    </ul>

    <ul class="plist2 clearfix" id="listProduct">
        <li class="clearfix" render-loop="list" ><a data-href="/mall/productDetail.html?id=" class="tap clearfix">
            <div class="imgbox box-sizing"><img render-src="list.product.imgUrl" class="lazy" src="/mall/images/1f1.jpg"></div>
                <div class="text-box box-sizing">
                    <div class="name" render-html="list.product.info">利仁（Liven） DHG-233A 电火锅</div>
                    <div class="price-box">
                        <span class="red unit" render-html="list.product.credits">11000</span>积分
                        <span class="num"> x <i render-html="list.number">1</i></span>
                    </div>
                </div>
            </a>
        </li>
    </ul>

    <div class="title-bt">结算</div>
    <ul class="list-tab btline mt10 clearfix">
        <li class="item">
            <div class="tap">
                <span class="name">运费</span>
                <span class="dsp c5">免邮</span>
            </div>
        </li>
        <li class="item">
            <div class="tap">
                <span class="name">订单总额</span>
                <div class="transFee">
                    <span class="dsp">积分</span>
                    <span class="dsp" id="dsp">11000</span>
                </div>
            </div>
        </li>
    </ul>

    <div class="title-bt">支付方式</div>
    <ul class="list-tab mt10 mb10 btline clearfix" id="payment">
        <li class="item">
            <div class="tap pl-24 check">
                <div class="icon-24"><img src="/mall/images/zfb.png"></div>
                <span class="name">支付宝支付</span>
                <label class="ico-check active"><input type="radio"></label>
            </div>
        </li>
        <li class="item">
            <div class="tap pl-24 check">
                <div class="icon-24"><img src="/mall/images/weixin.png"></div>
                <span class="name">微信支付</span>
                <label class="ico-check"><input type="radio"></label>
            </div>
        </li>
        <li class="item">
            <div class="tap pl-24 check">
                <div class="icon-24"><img src="/mall/images/yinlian.png"></div>
                <span class="name">网银支付</span>
                <label class="ico-check"><input type="radio"></label>
            </div>
        </li>
    </ul>

    <!-- footer begin -->
    <div class="clear"></div>
    <nav class="bot-nav">
        <div class="count-box totalMoney">共计 1 件，总额：
            <!--渲染金额-->
            <span class="red unit"> <font class="unit" id="unit">11000</font>积分</span>
        </div>
        <a href="javascript:" class="ljgm-btn pa paying" id="immediatePayment">立即支付</a>
    </nav>
</div>
<script>
    //图片懒加载
    $("img.lazy").lazyload({
        effect: "fadeIn",
        threshold: 1000,
    });

    //支付方式选择
    $(function () {
        $("#payment .tap").bind({
            tap: function () {
                $("#payment .ico-check").removeClass("active");
                $(this).find(".ico-check").addClass("active");
            }
        });
    });
</script>

</body>
</html>

